﻿using Microsoft.Data.SqlClient;
using Microsoft.IdentityModel.Tokens;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Navigation;
using Wemail.DAL;
using Wemail.Views;

namespace Wemail.ViewModels
{
    public class LoginWindowViewModel : BindableBase
    {
        private string _username="admin";
        private string _password="123456";
        public string Username { get { return _username; } set { SetProperty(ref _username, value); } }
        public string Password { get { return _password;}set { SetProperty(ref _password, value);} }
        public ICommand LoginCommand { get => new DelegateCommand<object>(Login);  }

        SqlServerAccess sqlServerAccess = new SqlServerAccess();
        LoginWindow loginWindow = new LoginWindow();
        public LoginWindowViewModel()
        {

        }
        private void Login(object obj)
        {     
            //进行登录校验
            if (sqlServerAccess.IsValid(Username, Password))
            {
               (obj as Window).DialogResult=true;
            }
            else MessageBox.Show("账号或密码错误！");
        }

    }
}
